# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-16
# @File : 3_hook.py

import frida
import sys

str_host = "127.0.0.1:8877"
manager = frida.get_device_manager()
rdev = manager.add_remote_device(str_host)
session = rdev.attach("Momo")

scr = """
Java.perform(function () {
    var c = Java.use("com.immomo.framework.m.c.c");
    c.a.overload('java.lang.String', 'java.lang.String').implementation = function(str,str2){
        console.log("——————————————————————这是str",str);
        console.log("——————————————————————这是str2",str2);
        
        var res = this.a(str,str2)
        console.log("——————————————————————这是返回值",res);
        console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return res
    };
});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()
